package com.qf.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.pojo.DtsOrder;
import com.qf.vo.DayStatis;
import com.qf.vo.ShipChannelListVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 订单表 Mapper 接口
 * </p>
 *
 * @author zhaojian
 * @since 2021-05-12
 */
@Mapper
public interface DtsOrderMapper extends BaseMapper<DtsOrder> {

    /**
     * 按天统计 订单的数量及订单的金额
     *
     * @return
     */
    @Select("SELECT\n" +
            "\tcount( 1 ) cnts ,\n" +
            "\tsum( actual_price ) amts ,\n" +
            "\tDATE_FORMAT( add_time, '%Y-%m-%d' ) dayStr \n" +
            "FROM\n" +
            "\tdts_order \n" +
            "WHERE\n" +
            "\tadd_time > DATE_ADD( now(), INTERVAL - 30 DAY ) \n" +
            "GROUP BY\n" +
            "\tDATE_FORMAT( add_time, '%Y-%m-%d' )")
    List<DayStatis> findDayStatis();


    @Select("SELECT ship_channel as value , ship_express as  label FROM dts_order")
    List<ShipChannelListVo> listShipChannel();
}
